 var adminViewData = {
	logoUrl: '',
	article:{
		title: "",
		logoImg: "",
		channelId:"",
		keywords:"",
		content: "",
		intro: "",
		author: ""
	},
	formSaveArticle: {
		title: [
	        { required: true, message: '标题不能为空', trigger: 'blur' }
	    ],
	    intro: [
	        { required: true, message: '简介不能为空', trigger: 'blur' }
	    ],
	    author: [
	        { required: true, message: '作者不能为空', trigger: 'blur' }
	    ],
	    keywords: [
	        { required: true, message: '关键字不能为空', trigger: 'blur' }
	    ],
		content: [
	        { required: true, message: '内容不能为空', trigger: 'blur' }
	    ],
	    /*channelId: [
	        { required: true, message: '请选择类型', trigger: 'change' }
	    ]*/
	    },
		channels: []
};
var adminContainer = new Vue({
	el: '#container',
	data: function() {
		return adminViewData;
	},
	beforeCreate: function(){
		var vm = this;
		vm.$http.post('/channels').then((response) => {
			var res = response.data;
			if(res) {
				vm.channels = res;
			} 
		}, function(err) {});
	},
	methods: {
		save: function() {
			var vm = this;
			vm.$refs['formSaveArticle'].validate((valid) => {
				if(valid){
					vm.$http.post('/erp/article/save', JSON.stringify(vm.article)).then((response) => {
						var res = response.data;
						if(res.success) {
							vm.$Message.success('保存成功');
						} else {
							vm.$Message.error(res.errorMsg);
						}
					}, function(err) {});
				} else {
					vm.$Message.error("表单验证失败");
				}
			});
		},
		uploadSuccess: function(response, file, fileList){
			var upload = this.$refs.logoImg;
			this.article.logoImg = response.resultObject;
			this.logoUrl = response.imageUrl;
			upload.clearFiles();
		}
	}
});